<?php

include("admin_lock.php");



if(!isset($_POST['semester']) || !isset $_POST['subject'] || !isset $_POST['courseNumber'] || !isset $_POST['courseName'] || !isset $_POST['sectionNumber'] || !isset $_POST['description'] || !isset $_POST['instructor'] || !isset $_POST['time'] || !isset $_POST['days'] || !isset $_POST['building'] || !isset $_POST['room'])
{
	header("Location: createClass.php?error=1");
	die()
}

require("config.php");

$semester=$_POST['semester'];
$subject=$_POST['subject'];
$courseNum=$_POST['courseNumber'];
$courseName=$_POST['courseName'];
$sectionNum=$_POST['sectionNumber'];
$description=$_POST['description'];
$instructor=$_POST['instructor'];
$time=$_POST['time'];
$days=$_POST['days'];
$building=$_POST['building'];
$room=$_POST['room'];

$createCourseQuery="INSERT INTO Course (semester,subject,number,name,description,sectionNum) VALUES ($semester,$subject,$courseNum,$courseName,$sectionNum)";
$createSectionQuery="INSERT INTO Section (instructor,time,day,room,building) VALUES ($instructor,$time,$days,$building,$room)";

$courseResult=mysql_query(addslashes($createCourseQuery));
$sectionResult=mysql_query(addslashes($createSectionQuery));

if(!$courseResult || !$sectionResult)
{
	header("Location: createClass.php?");
}
else
{
	header("Location: admin.php");
}

?>
